<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/watch.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script src="../js/cookie.js"></script>
    <script src="../js/interface.js"></script>
    <script src="../js/watch.js"></script>

</head>

<body>
    <div class="header">
        <img src="../imges/header.png" alt="">
    </div>

    <div class="centent all">
        <h1>COD13使命召唤:无限战争</h1>
        <div>

        </div>
    </div>
    <!-- 尾部 -->
    <div class="footer all">
        <div class="footer-left fl">
            <div class="footer-top">
                <div>
                    <h3>客服中心</h3>
                    <p>客服在线时间:09:00 - 21:00</p>
                    <p>客服QQ: 123456789</p>
                </div>
                <div>
                    <h3>售后服务</h3>
                    <p>退款政策</p>
                    <p>换货政策</p>
                </div>
                <div>
                    <h3>关于</h3>
                    <p>
                        <span>招聘信息</span>
                        <span>网站地图</span>
                        <span>联系我们</span>
                        <span>媒体信息</span>
                    </p>
                </div>
            </div>
        </div>
        <div class="footer-right fr">
            <img src="../imges/sao.jpg" alt="">
            <p>3DM商城APP</p>
        </div>
        <div class="footer-bootom ">
            <p>CopyRight@2003-2018 www.3DMGAME.COM All Right Reserved</p>
            <p>京ICP备14006952号-1京网文(2016)1650-207号沪公网安备31011202006753号</p>
        </div>
    </div>
</body>
<script>

    var num = Number(location.search.slice(1))

    $.ajax({
        type: "post",
        url: "../php/id.php",
        data: {
            id: num
        },
        dataType: "json",
        success: function (res) {
            var { status, list } = res;
            if (status) {
                var html = "";
                list.forEach(({ title, img, oldmoney, money, id }) => {
                    html += `<h1>${title}</h1>
            <div>
                <div class="left">
                    <div class="preview-wapper">
                        <div class="preview">
                            <img class="smallImg" src="${img}" alt="">
                            <div class="shadow"></div>
                        </div>
                        <div class="preview-scale">
                            <img class="bigImg" src="${img}" alt="">
                        </div>
                    </div>
                    <div class="preview-info">
                    </div>
                </div>
                <div class="right">
                    <p><s>￥${oldmoney}</s>
                        <span>￥${money}.00</span>
                    </p>
                    <a href="javascript:;" class="jiaru">加入购物车</a>
                </div>
            </div>`;
                    $(".centent").html(html);
                    $(".right").on("click", ".jiaru", function () {
                        var lgc = getCookie("lgc");
                        if (!lgc) {
                            alert("请先登录")
                            location.href = "./index.html"
                        } else {
                            $.ajax({
                                type: "post",
                                url: "../php/jia.php",
                                data: { user: lgc, g_id: num, number: 1 },
                                dataType: "json",
                                success: function (result) {
                                    var { status, message } = result;
                                    console.log(status, message);
                                    if (status) {
                                        isUserOk = true;
                                    } else {
                                        throw message
                                    }
                                }
                            })
                            location.href = `./shoping.html?${num}`
                        }
                    })
                })
            }
        }
    })

    //鼠标划出事件
    $(".centent").on("mouseleave", ".preview", function () {
        $(".shadow").css("display", "none")
        $(".preview-scale").css("display", "none");
    })

    // 鼠标移动事件
    $(".centent").on("mousemove", ".preview", function (e) {
        $(".shadow").css("display", "block");
        $(".preview-scale").css("display", "block");
        var maxLeft = 200;
        var maxTop = 200;
        var e = e || window.event;
        var x = e.pageX - $(".preview-wapper").offset().left - 100;
        var y = e.pageY - $(".preview-wapper").offset().top - 100;
        x = Math.min(Math.max(0, x), maxLeft);
        y = Math.min(Math.max(0, y), maxTop);
        $(".shadow").css("left", x + "px")
        $(".shadow").css("top", y + "px")
        $(".bigImg").css("left", -2 * x + "px")
        $(".bigImg").css("top", -2 * y + "px")
    })

    console.log(1);
</script>

</html>